package Com.javaserver.servlet;

import Com.javaserver.bean.salary;
import Com.javaserver.dao.salaryserver;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/sadele")
public class salarydeleserverlet extends HttpServlet {
      salaryserver  sa=new salaryserver();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         String dele=req.getParameter("dele");
         salary s=new salary();
         s.setX_id(Integer.parseInt(dele));
         if (sa.sadele(s)==false){
             req.getSession().setAttribute("msg","删除失败");
             resp.sendRedirect(req.getContextPath()+"/salary.jsp");
         }else {
             List<salary> list=sa.salist(1);
             req.getSession().setAttribute("salarylist",list);
             req.getSession().setAttribute("msg","删除成功");
             resp.sendRedirect(req.getContextPath()+"/salary");
         }
    }
}
